#include "UTexturedButton.h"
#include "UControl.h"
#include "../UTextureManager.h"

using namespace std;

#define StippleY 5
#define StippleX 5

TTexturedButton::TTexturedButton(std::string TextureName, TRectangle rect)
: TButton(rect)
{
	texture = GTextureManager->getTexture(TextureName);
}

TTexturedButton::TTexturedButton(GLuint Texture, TRectangle rect)
: TButton(rect)
{
	texture = Texture;
}

void TTexturedButton::Draw( )
{
	if (Pressed) glTranslatef(1, 1, 0);

	glColor3f(1,1,1);
	glBindTexture(GL_TEXTURE_2D, texture);
	glEnable(GL_TEXTURE_2D);
	glBegin(GL_QUADS);
		glTexCoord2i(1,0); glVertex2i(Left	, Top);
		glTexCoord2i(0,0); glVertex2i(Right	, Top);
		glTexCoord2i(0,1); glVertex2i(Right	, Bottom);
		glTexCoord2i(1,1); glVertex2i(Left	, Bottom);
	glEnd();
	glDisable(GL_TEXTURE_2D);

	DrawFocusStippleLine();
	
	if (Pressed) glTranslatef(-1, -1, 0);
}



